
namespace Karma.Framework.Core.Modules.Reports.Definition.Expression
{
    internal class ExpressionBuilder
    {
        public static IExpression Build(Criteria criterion)
        {
            IExpression expression = null;
            switch (criterion.Type)
            {
                case CriteriaType.And:
                    expression = new AndExpression(criterion);
                    break;
                case CriteriaType.Between:
                    expression = new BetweenExpression(criterion);
                    break;
                case CriteriaType.EndsWith:
                    expression = new EndsWithExpression(criterion);
                    break;
                case CriteriaType.Equal:
                    expression = new EqualExpression(criterion);
                    break;
                case CriteriaType.GreaterThan:
                    expression = new GreaterThanExpression(criterion);
                    break;
                case CriteriaType.GreaterThanOrEqual:
                    expression = new GreaterThanOrEqualExpression(criterion);
                    break;
                case CriteriaType.In:
                    expression = new InExpression(criterion);
                    break;
                case CriteriaType.LessThan:
                    expression = new LessThanExpression(criterion);
                    break;
                case CriteriaType.LessThanOrEqual:
                    expression = new LessThanOrEqualExpression(criterion);
                    break;
                case CriteriaType.Like:
                    expression = new LikeExpression(criterion);
                    break;
                case CriteriaType.Not:
                    expression = new NotExpression(criterion);
                    break;
                case CriteriaType.Or:
                    expression = new OrExpression(criterion);
                    break;
                case CriteriaType.StartsWith:
                    expression = new StartsWithExpression(criterion);
                    break;
                case CriteriaType.Contains:
                    expression = new ContainsExpression(criterion);
                    break;
                case CriteriaType.NotIn:
                    expression = new NotInExpression(criterion);
                    break;
                case CriteriaType.Distinct:
                    expression = new DistinctExpression(criterion);
                    break;
                case CriteriaType.NotLike:
                    expression = new NotLikeExpression(criterion);
                    break;
            }
            return expression;
        }
    }
}